<template>
	<view class="content-box">
		<form-render
			mode="MOBILE"
			class="form-design"
			ref="form"
			:forms="data.formItems"
			:value="data.formData"
		/>
	</view>
</template>

<script>
import FormRender from '@/subPackagesIndex/pages/index/approval/launch/forms/FormRender.vue'
export default {
	components: { FormRender },
	props: {
		data: {
			type: Object,
			value: {},
		},
	},
	data() {
		return {}
	},
	methods: {
		isShow(value) {
			const data = this.data.formData[value.id]
			if (!data) {
				return false
			} else {
				return true
			}
		},
		//内容展示
		filterContent(labelValue, contentVal) {
			if (contentVal || (contentVal && contentVal.length > 0)) {
				switch (labelValue) {
					case 'TimeRangePicker': {
						const newArr = contentVal.map((i) =>
							i.replace(/-/g, '/').substr(0, 16)
						)
						return newArr.join('-')
					}
					case 'DateTimeRange': {
						const newArr = contentVal.map((i) =>
							i.replace(/-/g, '/').substr(0, 16)
						)
						return newArr.join('-')
					}
					case 'TableList': {
						break
					}
					case 'ImageUpload': {
						return (
							contentVal &&
							contentVal.length > 0 &&
							contentVal.map((i) => i.url)
						)
					}
					case 'AmountInput': {
						return contentVal + '元'
					}
					case 'TextInput': {
						if (contentVal.toString().indexOf('{') === 0) {
							let obj = JSON.parse(contentVal)
							return obj.text
						} else {
							return contentVal
						}
					}
					default:
						return contentVal
				}
			}
		},
	},
}
</script>

<style scoped lang="scss">
.content-box {
	font-size: 34rpx;
}
/deep/.form-design {
	.uni-forms-item {
		margin-bottom: 0rpx !important;
	}
}
</style>
